function createUserList() {
  return [
    {
      userId: 1,
      avatar: 'https://img.eanchao.com/static/1.png',
      username: 'admin',
      password: '123456',
      desc: '管理员',
      roles: ['管理员'],
      buttons: ['cuser.detail'],
      routes: ['home'],
      token: 'AdminToken',
    },
    {
      userId: 2,
      avatar: 'https://img.eanchao.com/static/2.png',
      username: 'system',
      password: '123456',
      desc: '管理员',
      roles: ['管理员'],
      buttons: ['cuser.detail', 'cuser.user'],
      routes: ['home'],
      token: 'AdminToken',
    },
  ]
}

export default [
  {
    url: '/api/user/login',
    method: 'post',
    response: ({ body }) => {
      const { username, password } = body
      const checkUser = createUserList().find(
        (item) => item.username === username && item.password === password,
      )
      if (!checkUser) {
        return { code: 201, data: { message: '账号或密码不正确' } }
      }
      const { token } = checkUser
      return { code: 200, data: { token } }
    },
  },
  {
    url: '/api/user/info',
    method: 'get',
    response: (request) => {
      const token = request.header.token
      const checkUser = createUserList().find((item) => item.token === token)
      if (!checkUser) {
        return { code: 201, data: { message: '获取用户信息失败' } }
      }
      return { code: 200, data: { checkUser } }
    },
  },
]
